package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

class znx {
   String a;
   String b;
   ArrayList c = new ArrayList();
   HashMap d = new HashMap();
   HashMap e = new HashMap();
   ArrayList f = new ArrayList();
   zol g = null;
   Chart h = null;
   zny[] i;
   ArrayList j = new ArrayList();

   zok a() {
      return this.g.e;
   }

   znx(znw var1) {
      this.g = var1.g;
      this.h = var1.a;
      this.a(this.h.l());
      this.i = this.c();
      if (this.i != null && this.i.length > 0) {
         this.b = "drawing" + zase.y(this.a().b()) + ".xml";
      }

   }

   znx(zol var1) {
      this.g = var1;
      Worksheet var2 = var1.a;
      if (var2.getType() == 2) {
         Chart var3 = var2.getCharts().get(0);
         this.a(var3);
         this.b = "drawing" + zase.y(this.a().b()) + ".xml";
      } else {
         this.a(var2.t());
         this.i = this.c();
         if (this.i != null && this.i.length > 0) {
            this.b = "drawing" + zase.y(this.a().b()) + ".xml";
         }
      }

      if (this.c.size() == 0) {
         this.d = null;
      }

   }

   private void a(ShapeCollection var1) {
      if (var1 != null) {
         ArrayList var2 = var1.a();
         if (var2 != null && var2.size() > 0) {
            com.aspose.cells.b.a.a.ze.a(this.c, (Collection)var2);
         }
      }

   }

   String a(byte[] var1) throws Exception {
      if (var1 != null && var1.length != 0) {
         zom var2 = new zom();
         var2.a = var1;
         var2.b = zase.a("image", this.a().d(), var1);
         com.aspose.cells.b.a.a.ze.a(this.j, (Object)var2);
         var2.c = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", "../media/" + var2.b, (String)null);
         return var2.c;
      } else {
         return null;
      }
   }

   private ShapeCollection b() {
      return this.h != null ? this.h.l() : this.g.a.t();
   }

   private zny[] c() {
      ShapeCollection var1 = this.b();
      if (var1 != null && var1.getCount() != 0) {
         int var2 = var1.getCount();
         zny[] var3 = new zny[var2];
         int var4 = 0;
         int var5 = -1;
         Iterator var6 = var1.iterator();

         while(true) {
            Shape var7;
            boolean var8;
            while(true) {
               do {
                  if (!var6.hasNext()) {
                     zny[] var13 = new zny[var4];
                     System.arraycopy(var3, 0, var13, 0, var4);
                     return var13;
                  }

                  var7 = (Shape)var6.next();
                  ++var5;
                  var8 = var7.af();
               } while(var8 && var7.x == null && var7.getMsoDrawingType() != 24 && (var7.getMsoDrawingType() != 8 || ((Picture)var7).ac() == null));

               if (var7.getMsoDrawingType() == 8 && var7.x == null) {
                  Picture var14 = (Picture)var7;
                  boolean var10 = false;
                  String var11;
                  if (var14.d()) {
                     var10 = true;
                     if (!this.d.containsKey(var14.getSourceFullName())) {
                        var11 = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", var14.getSourceFullName(), "External");
                        this.d.put(var14.getSourceFullName(), var11);
                     }
                  }

                  String var12;
                  if (var14.b() == 0) {
                     if (!var10 && !this.d.containsKey(var14.b())) {
                        var11 = "NULL";
                        var12 = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", var11, (String)null);
                        this.d.put(var14.b(), var12);
                     }
                     break;
                  }

                  if (!this.a().f.containsKey(var14.b())) {
                     continue;
                  }

                  if (!this.d.containsKey(var14.b())) {
                     var11 = "../media/" + (String)this.a().f.get(var14.b());
                     var12 = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", var11, (String)null);
                     this.d.put(var14.b(), var12);
                  }
                  break;
               }

               if (var7.getMsoDrawingType() == 5) {
                  Chart var9 = ((ChartShape)var7).getChart();
                  this.a(var9);
               }
               break;
            }

            if (var7.getHyperlink() != null) {
               this.a(var7.getHyperlink());
            }

            zny var15 = new zny(this, var7, var8);
            if (var15.b && var8 && this.g != null && this.h == null) {
               this.g.w.put(var5, var15);
            }

            if (!var7.S()) {
               var3[var4++] = var15;
            }
         }
      } else {
         return null;
      }
   }

   private void a(Chart var1) {
      znw var2 = new znw(this.g, var1);
      ++this.a().k;
      var2.b = this.a().k;
      String var3 = "../charts/chart" + zase.y(var2.b) + ".xml";
      var2.e = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", var3, (String)null);
      com.aspose.cells.b.a.a.ze.a(this.f, (Object)var2);
   }

   private void a(Hyperlink var1) {
      if (var1 != null) {
         String var2 = null;
         int var3 = var1.a(this.a().a.getWorksheets());
         if (var3 != 0 && var3 != 1) {
            var2 = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", "#" + var1.getAddress(), (String)null);
         } else {
            String var4 = com.aspose.cells.b.a.zv.a(var1.getAddress(), " ", "%20");
            if (var3 == 1 && var4.indexOf(":") != -1) {
               var4 = "file:///" + var4;
            }

            var2 = this.a("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", var4, "External");
         }

         this.e.put(var1, var2);
      }
   }

   String a(String var1, String var2, String var3) {
      String var4 = "rId" + this.d();
      zqe var5 = new zqe(var4, var1, var2, var3);
      com.aspose.cells.b.a.a.ze.a(this.c, (Object)var5);
      return var4;
   }

   private int d() {
      int var1 = this.c.size();
      int var2 = this.c.size();

      for(int var3 = 0; var3 < var2; ++var3) {
         zqe var4 = (zqe)this.c.get(var3);

         try {
            int var5 = zase.C(var4.c.substring(3));
            if (var5 > var1) {
               var1 = var5;
            }
         } catch (Exception var6) {
            ;
         }
      }

      return var1 + 1;
   }
}
